package com.demo.controller;

import com.demo.common.Result;
import com.demo.service.IntelligentScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

/**
 * 排课测试控制器
 */
@RestController
@RequestMapping("/test")
@CrossOrigin
public class ScheduleTestController {
    
    @Autowired
    @Qualifier("simpleScheduleService")
    private IntelligentScheduleService intelligentScheduleService;
    
    /**
     * 测试智能排课
     */
    @PostMapping("/intelligent-schedule/{semester}")
    public Result<String> testIntelligentSchedule(@PathVariable String semester) {
        try {
            System.out.println("开始测试智能排课，学期：" + semester);
            boolean success = intelligentScheduleService.executeIntelligentSchedule(semester);
            if (success) {
                return Result.success("智能排课测试成功");
            } else {
                return Result.error("智能排课测试失败");
            }
        } catch (Exception e) {
            System.err.println("智能排课测试异常：" + e.getMessage());
            e.printStackTrace();
            return Result.error("智能排课测试异常：" + e.getMessage());
        }
    }
}


